package com.ks.repair.controller;


import com.ks.core.base._ControllerBase;
import com.ks.core.core.Result;
import com.ks.core.dto.OperateBase;
import com.ks.core.dto.SearchCriteriaBase;
import com.ks.repair.controller.dto.RepairBillRequest;
import com.ks.repair.entity.*;
import com.ks.repair.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 报修-会员填写的报修单 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-15
 */
@RestController
@RequestMapping("/bRepairBill")
@Api(value = "管理模块", description = "管理模块")
public class BRepairBillController extends _ControllerBase {

    @Autowired
    private IBRepairBillService bRepairBillService;

    @Autowired
    private IBRepairFeesService bRepairFeesService;

    @Autowired
    private IBRepairClassService bRepairClassService;

    @Autowired
    private IBRepairBillTemplateService bRepairBillTemplateService;


    @PostMapping("/selectRepairTemplate")
    @ApiOperation(value = "报修单模板字段列表查询接口", notes = "报修单模板字段列表查询接口")
    public Object selectRepairTemplate(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = bRepairBillTemplateService.selectRepairTemplate(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/getBRepairBillUserCount")
    @ApiOperation(value = "租户累计收到商机", notes = "租户累计收到商机")
    public Object getBRepairBillUserCount() {
        Map<String, Object> bRepairBillUserCount = bRepairBillService.getBRepairBillUserCount(getContext());
        return Result.success(bRepairBillUserCount);
    }

    @PostMapping("/getBRepairBillUserAddressCount")
    @ApiOperation(value = "租户报修省市占比图", notes = "租户报修省市占比图")
    public Object getBRepairBillUserAddressCount() {
        Map<String, Object> bRepairBillUserCount = bRepairBillService.getBRepairBillUserAddressCount(getContext());
        return Result.success(bRepairBillUserCount);
    }

    @PostMapping("/getServiceTypeUserCount")
    @ApiOperation(value = "租户报修类别雷达图", notes = "租户报修类别雷达图")
    public Object getServiceTypeUserCount() {
        Map<String, Object> bRepairBillUserCount = bRepairBillService.getServiceTypeUserCount(getContext());
        return Result.success(bRepairBillUserCount);
    }

    @PostMapping("/addRepairTemplate")
    @ApiOperation(value = "报修单模板字段添加接口", notes = "报修单模板字段添加接口")
    public Object addRepairTemplate(@RequestBody BRepairBillTemplate bRepairBillTemplate) {
        int i = bRepairBillTemplateService.addRepairTemplate(getContext(), bRepairBillTemplate);
        return Result.success(i);
    }


    @PostMapping("/updateRepairTemplate")
    @ApiOperation(value = "报修单模板字段修改接口", notes = "报修单模板字段修改接口")
    public Object updateRepairTemplate(@RequestBody BRepairBillTemplate bRepairBillTemplate) {
        int i = bRepairBillTemplateService.updateRepairTemplate(getContext(), bRepairBillTemplate);
        return Result.success(i);
    }


    @PostMapping("/deleteRepairTemplate")
    @ApiOperation(value = "报修单模板字段删除接口", notes = "报修单模板字段删除接口")
    public Object deleteRepairTemplate(@RequestBody OperateBase operateBase) {
        List i = bRepairBillTemplateService.deleteRepairTemplate(getContext(), operateBase);
        return Result.success(i);
    }


    @PostMapping("/selectRepairFees")
    @ApiOperation(value = "服务收费项列表查询接口", notes = "服务收费项列表查询接口")
    public Object selectRepairFees(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = bRepairFeesService.selectRepairFees(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/addRepairFees")
    @ApiOperation(value = "服务收费项添加接口", notes = "服务收费项添加接口")
    public Object addRepairFees(@RequestBody BRepairFees bRepairFees) {
        int i = bRepairFeesService.addRepairFees(getContext(), bRepairFees);
        return Result.success(i);
    }


    @PostMapping("/updateRepairFees")
    @ApiOperation(value = "服务收费项修改接口", notes = "服务收费项修改接口")
    public Object updateRepairFees(@RequestBody BRepairFees bRepairFees) {
        int i = bRepairFeesService.updateRepairFees(getContext(), bRepairFees);
        return Result.success(i);
    }


    @PostMapping("/deleteRepairFees")
    @ApiOperation(value = "服务收费项删除接口", notes = "服务收费项删除接口")
    public Object deleteRepairFees(@RequestBody OperateBase operateBase) {
        List i = bRepairFeesService.deleteRepairFees(getContext(), operateBase);
        return Result.success(i);
    }


    @PostMapping("/selectRepairList")
    @ApiOperation(value = "服务种类列表查询接口", notes = "服务种类列表查询接口")
    public Object selectRepairClass(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = bRepairClassService.selectRepairClass(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/addRepairClass")
    @ApiOperation(value = "服务种类添加接口", notes = "服务种类添加接口")
    public Object addRepairClass(@RequestBody BRepairClass bRepairClass) {
        int i = bRepairClassService.addRepairClass(getContext(), bRepairClass);
        return Result.success(i);
    }


    @PostMapping("/updateRepairClass")
    @ApiOperation(value = "服务种类修改接口", notes = "服务种类修改接口")
    public Object updateRepairClass(@RequestBody BRepairClass bRepairClass) {
        int i = bRepairClassService.updateRepairClass(getContext(), bRepairClass);
        return Result.success(i);
    }


    @PostMapping("/deleteRepairClass")
    @ApiOperation(value = "服务种类删除接口", notes = "服务种类删除接口")
    public Object deleteRepairClass(@RequestBody OperateBase operateBase) {
        int i = bRepairClassService.deleteRepairClass(getContext(), operateBase);
        return Result.success(i);
    }


    @PostMapping("/selectRepairBillList")
    @ApiOperation(value = "报修单列表查询接口", notes = "报修单列表查询接口")
    public Object selectRepairBillList(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> resultMap = bRepairBillService.selectRepairBillList(getContext(), searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/selectRepairBill")
    @ApiOperation(value = "报修单详情查询接口", notes = "报修单详情查询接口")
    public Object selectRepairBill(@RequestBody RepairBillRequest repairBillRequest) {
        Map<String, Object> resultMap = bRepairBillService.selectRepairBill(getContext(), repairBillRequest);
        return Result.success(resultMap);
    }


}

